package cn.edu.nju.ws.sview.reasoning.schema;

import java.util.HashSet;

/**
 * class node or property node
 * @author ssgong
 *
 */
public class Node {
   private HashSet<Node> parents=null;
   private HashSet<Node> children=null;
   private HashSet<Integer> ids=null ;
   
   public Node(HashSet<Integer> ids){
	   this.ids  = ids;
	   this.parents = new HashSet<Node>();
	   this.children = new HashSet<Node>();
   }
   
   public void addParent(Node parent){
	   this.parents.add(parent) ;
   }
   
   public void addChildren(Node child){
	   this.children.add(child);
   }
   
   public void deleteParent(Node parent){
	   this.parents.remove(parent);
   }
   
   public void deleteChild(Node child){
	   this.children.remove(child) ;
   }

@Override
public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + ((children == null) ? 0 : children.hashCode());
	result = prime * result + ((ids == null) ? 0 : ids.hashCode());
	result = prime * result + ((parents == null) ? 0 : parents.hashCode());
	return result;
}

@Override
public boolean equals(Object obj) {
	if (this == obj)
		return true;
	if (obj == null)
		return false;
	if (getClass() != obj.getClass())
		return false;
	Node other = (Node) obj;
	if (children == null) {
		if (other.children != null)
			return false;
	} else if (!children.equals(other.children))
		return false;
	if (ids == null) {
		if (other.ids != null)
			return false;
	} else if (!ids.equals(other.ids))
		return false;
	if (parents == null) {
		if (other.parents != null)
			return false;
	} else if (!parents.equals(other.parents))
		return false;
	return true;
}
  
}
